﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="创建数据库.aspx.cs" Inherits="SQL存储过程_创建数据库" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Panel ID="Panel1" runat="server" Width="80%" BorderWidth="1px">
            <h3 style="margin: 8pt 0cm">
                <span lang="EN-US">CREATE DATABASE</span><span style="font-family: 黑体; mso-ascii-font-family: 'Times New Roman'">指令</span></h3>
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt">
                <span style="font-size: 10pt"><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                    mso-hansi-font-family: 'Times New Roman'">除了前面介绍的两种图形化接口方式建立数据库外，也可以利用</span><span
                        lang="EN-US">Transact-SQL</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                            mso-hansi-font-family: 'Times New Roman'">的语法来建立数据库。建立数据库的</span><span lang="EN-US">Transact-SQL</span><span
                                style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">指令为</span><span
                                    lang="EN-US">CREATE DATABASE</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                                        mso-hansi-font-family: 'Times New Roman'">指令，其使用语法如下：</span></span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span lang="EN-US" style="font-family: Courier New">CREATE
                    DATABASE </span><span style="font-family: 宋体; mso-ascii-font-family: 'Courier New';
                        mso-hansi-font-family: 'Courier New'">数据库名称</span><span lang="EN-US" style="font-family: Courier New">
                        </span></span>
            </p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span lang="EN-US" style="font-size: 9pt; font-family: Courier New">[ ON </span>
            </p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span lang="EN-US"><span style="font-family: Courier New">
                    <span style="mso-spacerun: yes">&nbsp; &nbsp; </span>[PRIMARY<span style="mso-spacerun: yes">&nbsp;
                    </span></span></span><span style="font-family: 宋体; mso-ascii-font-family: 'Courier New';
                        mso-hansi-font-family: 'Courier New'">（主数据文件）</span><span lang="EN-US" style="font-family: Courier New">[,</span><span
                            style="font-family: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">（次数据文件）</span><span
                                lang="EN-US" style="font-family: Courier New">[, ...n]]</span></span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span lang="EN-US"><span style="font-family: Courier New">
                    <span style="mso-spacerun: yes">&nbsp; &nbsp; </span>[ , FILEGROUP </span></span>
                    <span style="font-family: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">
                        文件组名称</span><span lang="EN-US"><span style="font-family: Courier New; mso-spacerun: yes">&nbsp;
                        </span></span><span style="font-family: 宋体; mso-ascii-font-family: 'Courier New';
                            mso-hansi-font-family: 'Courier New'">（次数据文件）</span><span lang="EN-US" style="font-family: Courier New">[,
                                ...n]] </span></span>
            </p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span lang="EN-US" style="font-size: 9pt; font-family: Courier New">] </span>
            </p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span lang="EN-US" style="font-family: Courier New">[ LOG
                    ON </span><span style="font-family: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">
                        （事务日志文件）</span><span lang="EN-US" style="font-family: Courier New">[, ...n] ] </span>
                </span>
            </p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span lang="EN-US" style="font-family: Courier New">[ COLLATE
                </span><span style="font-family: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">
                    默认置序</span><span lang="EN-US" style="font-family: Courier New"> ]</span></span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span lang="EN-US" style="font-size: 9pt; font-family: Courier New">[ FOR LOAD | FOR
                    ATTACH ] </span>
            </p>
            <p class="MsoNormal" style="margin: 6pt 0cm 0pt">
                <span style="font-size: 10pt"><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                    mso-hansi-font-family: 'Times New Roman'">数据文件（主数据文件与次数据文件）与事务日志文件的设置格式如下，定义的内容包括：名称（</span><span
                        lang="EN-US">Name</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                            mso-hansi-font-family: 'Times New Roman'">）、文件名称（</span><span lang="EN-US">FILENAME</span><span
                                style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）、起始大小（</span><span
                                    lang="EN-US">SIZE</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                                        mso-hansi-font-family: 'Times New Roman'">）、最大增长值（</span><span lang="EN-US">MAXSIZE</span><span
                                            style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）以及增长量（</span><span
                                                lang="EN-US">FILEGROWTH</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                                                    mso-hansi-font-family: 'Times New Roman'">）。</span></span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span lang="EN-US"><span style="font-family: Courier New">
                    <span style="mso-spacerun: yes">&nbsp;</span>(<span style="mso-spacerun: yes">&nbsp;
                    </span>NAME = </span></span><span style="font-family: 宋体; mso-ascii-font-family: 'Courier New';
                        mso-hansi-font-family: 'Courier New'">名称</span><span lang="EN-US" style="font-family: Courier New">
                            , </span></span>
            </p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span lang="EN-US"><span style="font-family: Courier New">
                    <span style="mso-spacerun: yes">&nbsp; &nbsp; </span>FILENAME = </span></span><span
                        style="font-family: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">
                        文件名称</span><span lang="EN-US" style="font-family: Courier New">,</span></span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span lang="EN-US"><span style="font-family: Courier New">
                    <span style="mso-spacerun: yes">&nbsp; &nbsp; </span>SIZE = </span></span><span style="font-family: 宋体;
                        mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">起始大小</span><span
                            lang="EN-US" style="font-family: Courier New"> ,</span></span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span lang="EN-US"><span style="font-family: Courier New">
                    <span style="mso-spacerun: yes">&nbsp; &nbsp; </span>MAXSIZE = { </span></span><span
                        style="font-family: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">
                        最大限制</span><span lang="EN-US" style="font-family: Courier New"> | UNLIMITED } ,</span></span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span lang="EN-US"><span style="font-family: Courier New">
                    <span style="mso-spacerun: yes">&nbsp; &nbsp; </span>FILEGROWTH = </span></span>
                    <span style="font-family: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">
                        增长量</span><span lang="EN-US"><span style="font-family: Courier New"><span style="mso-spacerun: yes">&nbsp;
                        </span>)</span></span></span></p>
            <p class="MsoNormal" style="margin: 6pt 0cm 0pt">
                <span style="font-size: 10pt"><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                    mso-hansi-font-family: 'Times New Roman'">这样一大串的指令，看似有点复杂，但其实只要弄清楚创建数据库时的几个设置项目，然后在</span><span
                        lang="EN-US">CREATE DATABASE</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                            mso-hansi-font-family: 'Times New Roman'">指令中指定特殊要设置的部分，其余没设置的部分就采用默认值。例如，建立数据库最简单的指令就是：</span></span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span lang="EN-US" style="font-size: 9pt; font-family: Courier New">CREATE DATABASE
                    db1</span></p>
            <p class="MsoNormal" style="margin: 6pt 0cm 0pt">
                <span style="font-size: 10pt"><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                    mso-hansi-font-family: 'Times New Roman'">这行</span><span lang="EN-US">CREATE DATABASE</span><span
                        style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">指令将会使用默认值在</span><span
                            lang="EN-US">SQL</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                                mso-hansi-font-family: 'Times New Roman'">服务器上建立一个名为“</span><span lang="EN-US">db</span><span
                                    style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">”的数据库。</span></span></p>
            <p class="MsoNormal" style="margin: 0cm 0cm 0pt">
                <span style="font-size: 10pt"><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                    mso-hansi-font-family: 'Times New Roman'">如果要自行指定数据文件与事务日志文件的文件位置与自动增长特性，例如，要建立一个名称为“</span><span
                        lang="EN-US">DB2</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                            mso-hansi-font-family: 'Times New Roman'">”的数据库，其数据文件的名称为“</span><span lang="EN-US">db2_data</span><span
                                style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">”、文件名为“</span><span
                                    lang="EN-US">C:\DATABASE\DB2.MDF</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                                        mso-hansi-font-family: 'Times New Roman'">”、初始大小为“</span><span lang="EN-US">10MB</span><span
                                            style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">”、最大值为“</span><span
                                                lang="EN-US">50MB</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                                                    mso-hansi-font-family: 'Times New Roman'">”、每次增长“</span><span lang="EN-US">1MB</span><span
                                                        style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">”；其事务日志文件的名称为“</span><span
                                                            lang="EN-US">db2_log</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                                                                mso-hansi-font-family: 'Times New Roman'">”、文件名为“</span><span lang="EN-US">C:\DATABASE\DB2.LDF</span><span
                                                                    style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">”、初始大小为“</span><span
                                                                        lang="EN-US">10MB</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                                                                            mso-hansi-font-family: 'Times New Roman'">”、文件无最大值、每次增长“</span><span lang="EN-US">10%</span><span
                                                                                style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">”，可以使用下列</span><span
                                                                                    lang="EN-US">CREATE DATABASE</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                                                                                        mso-hansi-font-family: 'Times New Roman'">指令完成。</span></span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span lang="EN-US" style="font-size: 9pt; font-family: Courier New">CREATE DATABASE
                    db2</span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span lang="EN-US" style="font-size: 9pt; font-family: Courier New">ON PRIMARY</span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span style="font-family: 宋体; mso-ascii-font-family: 'Courier New';
                    mso-hansi-font-family: 'Courier New'">（</span><span lang="EN-US" style="font-family: Courier New">NAME
                        = db2_data,</span></span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span lang="EN-US" style="font-size: 9pt; font-family: Courier New">FILENAME = ‘C:\DATABASE\DB2.MDF’,</span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span lang="EN-US" style="font-size: 9pt; font-family: Courier New">SIZE = 10 ,</span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span lang="EN-US" style="font-size: 9pt; font-family: Courier New">MAXSIZE = 50,</span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span lang="EN-US" style="font-family: Courier New">FILEGROWTH
                    = 1 </span><span style="font-family: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">
                        ）</span></span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span lang="EN-US" style="font-size: 9pt; font-family: Courier New">LOG ON</span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span style="font-family: 宋体; mso-ascii-font-family: 'Courier New';
                    mso-hansi-font-family: 'Courier New'">（</span><span lang="EN-US" style="font-family: Courier New">NAME
                        = db2_Log,</span></span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span lang="EN-US" style="font-size: 9pt; font-family: Courier New">FILENAME = ‘C:\DATABASE\DB2.LDF’,</span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span lang="EN-US" style="font-size: 9pt; font-family: Courier New">SIZE = 10 ,</span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span lang="EN-US" style="font-size: 9pt; font-family: Courier New">MAXSIZE = UNLIMITED,</span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span lang="EN-US" style="font-family: Courier New">FILEGROWTH
                    = 10% </span><span style="font-family: 宋体; mso-ascii-font-family: 'Courier New';
                        mso-hansi-font-family: 'Courier New'; font-size: 9pt; color: teal;">）</span></span></p>
            <p>
                <span></span><span style="mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">
                </span>/*
            </p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span lang="EN-US"><span style="font-family: Courier New">
                    <span style="mso-spacerun: yes">&nbsp;</span>(<span style="mso-spacerun: yes">&nbsp;
                    </span>NAME = </span></span><span style="font-family: 宋体; mso-ascii-font-family: 'Courier New';
                        mso-hansi-font-family: 'Courier New'">名称</span><span lang="EN-US" style="font-family: Courier New">
                            , </span></span>
            </p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span lang="EN-US"><span style="font-family: Courier New">
                    <span style="mso-spacerun: yes">&nbsp; &nbsp; </span>FILENAME = </span></span><span
                        style="font-family: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">
                        文件名称</span><span lang="EN-US" style="font-family: Courier New">,</span></span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span lang="EN-US"><span style="font-family: Courier New">
                    <span style="mso-spacerun: yes">&nbsp; &nbsp; </span>SIZE = </span></span><span style="font-family: 宋体;
                        mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">起始大小</span><span
                            lang="EN-US" style="font-family: Courier New"> ,</span></span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span lang="EN-US"><span style="font-family: Courier New">
                    <span style="mso-spacerun: yes">&nbsp; &nbsp; </span>MAXSIZE = { </span></span><span
                        style="font-family: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">
                        最大限制</span><span lang="EN-US" style="font-family: Courier New"> | UNLIMITED } ,</span></span></p>
            <p class="a" style="margin: 0cm 0cm 0pt; text-indent: 18.9pt">
                <span style="font-size: 9pt"><span lang="EN-US"><span style="font-family: Courier New">
                    <span style="mso-spacerun: yes">&nbsp; &nbsp; </span>FILEGROWTH = </span></span>
                    <span style="font-family: 宋体; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'">
                        增长量</span><span lang="EN-US"><span style="font-family: Courier New"><span style="mso-spacerun: yes">&nbsp;
                        </span>)</span></span></span></p>
            <p>
                */</SPAN></SPAN></p>
            <p class="MsoNormal" style="margin: 6pt 0cm 0pt">
                <span style="font-size: 10pt"><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                    mso-hansi-font-family: 'Times New Roman'">有关</span><span lang="EN-US">DATABASE</span><span
                        style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">指定的使用语法，就简单介绍到此，如果需要更详细的使用说明，可以参考“</span><span
                            lang="EN-US">SQL</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman';
                                mso-hansi-font-family: 'Times New Roman'">线上说明”。其他有关</span><span lang="EN-US">Transact-SQL</span><span
                                    style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的使用，将会在第八章中详细介绍。</span></span></p>
        </asp:Panel>
    
    </div>
    </form>
</body>
</html>
